#ifdef MINI_MMI

byte Par[10];

void UserPlugin_MMI_Periodically()
{
  UserPlugin_MiniMMI();
  return;
}

void UserPlugin_MiniMMI(void)
{
  byte SerialInByte;

  if(Serial.available())
  {
    delay(50);
    for(byte x=0; x < 10; x++) Par[x]=0;
    SerialInByte=Serial.read();

    if (SerialInByte > 10) SerialInByte=10;

    for(byte x=0; x < SerialInByte; x++) Par[x]=Serial.read();

    if (Par[0] == 's')
      {
        int baseaddress=sizeof(struct SettingsStruct);
        Serial.write(0xff); // Byte value to signal start of binary data
        Serial.write((byte)(EVENTLIST_MAX*8+1) & 0xff); // send message length, LSB
        Serial.write((byte)(((EVENTLIST_MAX*8+1) >> 8) & 0xff)); // send message length, MSB
        Serial.write(0x1); // send messagetype (1=eventlistshow)
        for (int x=0; x < EVENTLIST_MAX*8; x++) Serial.write(EEPROM.read(baseaddress+x));
      }
      
    if (Par[0] == 'c')
      {
        unsigned long event=0L;
        for (byte x=1; x < 5; x++)
          {
            if ((x==1) && ((Par[x] & 0xf0) == 16)) Par[x]=Par[x]+Settings.Unit;
            event = event + ((unsigned long)Par[x] << (8*(4-x)));
          }
        ExecuteCommand(event,VALUE_SOURCE_RF,0,0);
      }
      
    if (Par[0] == 'w')
      {
        int baseaddress=sizeof(struct SettingsStruct)+(Par[1]-1)*8;
        for (byte x=2; x < 10; x++)
          {
            if ((x==2 || x==6)  && ((Par[x] & 0xf0) == 16)) Par[x]=Par[x]+Settings.Unit;
            EEPROM.write(baseaddress+x-2, Par[x]);
          }
      }

    Serial.println("ok");
  }
}
#endif // MINI MMI

